package com.sc.nft.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.dao.RoleDao;
import com.sc.nft.entity.Role;
import com.sc.nft.service.RoleService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 角色表服务接口实现
 *
 * @author zhangxiangyu
 * @since 2022-02-02 17:11:20
 * @description 
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class RoleServiceImpl implements RoleService {
    private final RoleDao roleDao;


    @Override
    public Role queryById(Long id) {
        if(id==null){
            Role role = new Role();
            role.setRoleName("超级管理员");
            return role;
        }
        return roleDao.getById(id);
    }

    @Override
    public Boolean checkRoleNameExists(String roleName) {
        return roleDao.selectByRoleName(roleName)!=null;
    }

    @Override
    public Page<Role> queryRoles(String roleName, long pageNo, long pageSize) {
        return roleDao.queryLikeRoleName(roleName, pageNo, pageSize);
    }
}